import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
    {
        path: '/',
        component: () => import('../views/Main.vue'),
        redirect: '/home',
        children: [
            {
                path: '/home',
                name: 'home',
                component: () => import('../views/home/Home.vue'),

                // 独享守卫
                // beforeEnter: (to, from, next) => {
                //     console.log('to---', to);
                //     console.log('from---', from);
                //     next()
                // }
            },
            {
                path: '/mall',
                name: 'mall',
                component: () => import('../views/mall/Mall.vue'),
            },
            {
                path: '/user',
                name: 'user',
                component: () => import('../views/user/User.vue')
            },
            {
                path: '/page1',
                name: 'page1',
                component: () => import('../views/other/Other1.vue')
            },
            {
                path: '/page2',
                name: 'page2',
                component: () => import('../views/other/Other2.vue')
            },
            {
                path: '/music',
                name: 'music',
                component: () => import('../views/music/Music.vue')
            }
        ],
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../views/login/Login.vue')
    },
    {
        path: '/:path(.*)',
        name: 'notviews',
        component: () => import('../views/notViews/NotViews.vue')
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})



// 全局守卫

// router.beforeEach((to, from,next) => {
//     console.log('to---',to);
//     console.log('from---',from);
//     next()
//     console.log('next---',next);
// })

export default router